import Layout from '@/layout'

// 静态路由（默认路由）(常量路由) 所有的用户都可以看到的菜单路由
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },
]

// 定义动态路由(异步路由)根据用户登录返回的路由权限信息决定从动态路由中取出路由
export const allAsyncRoutes = [
  // 商品管理路由
  {
    path: '/product',
    component: Layout,
    redirect: '/product/Category',
    name: 'Product',
    meta: { title: '商品管理', icon: 'el-icon-sell' },
    children: [
      {
        path: 'trademark',
        name: 'Trademark',
        component: () => import('@/views/product/Trademark/index.vue'),
        meta: { title: '品牌管理', icon: 'el-icon-bank-card' }
      },
      {
        path: 'attr',
        name: 'Attr',
        component: () => import('@/views/product/Attr/index.vue'),
        meta: { title: '平台属性管理', icon: 'el-icon-film' }
      },
      {
        path: 'spu',
        name: 'Spu',
        component: () => import('@/views/product/Spu/index.vue'),
        meta: { title: 'Spu管理', icon: 'el-icon-notebook-2' }
      },
      {
        path: 'sku',
        name: 'Sku',
        component: () => import('@/views/product/Sku/index.vue'),
        meta: { title: 'Sku管理', icon: 'el-icon-notebook-1' }
      },
    ]
  },
  // 权限管理
  {
    path: '/acl',
    component: Layout,
    redirect: '/acl/permission',
    name: 'Acl',
    meta: { title: '权限管理', icon: 'el-icon-setting' },
    children: [
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/acl/user/index.vue'),
        meta: { title: '用户管理' }
      },
      {
        path: 'role',
        name: 'Role',
        component: () => import('@/views/acl/role/index.vue'),
        meta: { title: '角色管理' }
      },
      {
        name: "RoleAuth",
        path: "role/auth",
        component: () => import("@/views/acl/role/roleAuth.vue"),
        hidden: true,
      },
      {
        path: 'permission',
        name: 'Permission',
        component: () => import('@/views/acl/permission/index.vue'),
        meta: { title: '菜单管理' }
      },

    ]
  },
  // example
  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },
  // form
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form' }
      }
    ]
  },
  // nested
  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        name: 'Menu2',
        meta: { title: 'menu2' }
      }
    ]
  },
  // external-link
  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },
]
//  任意路由:：这个路由是用户随意输入路径的时候要匹配的，最终重定向到404，这个路由在注册的时候，必须是注册在最后一个
export const anyRoutes = [
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]